<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">"???"</text>
		</view>
		<button @click="handleClick">点我</button>
		<button @click="handleLogin">登录</button>
		<button @click="handleScancode">扫码</button>
	</view>
</template>

<script setup lang="ts">
	function handleClick() {
		console.log("clicked ....")
		uni.showToast({
			icon: 'none',
			title: 'clicked'
		})
	}

	function handleLogin() {
		wx.login({
			success(res) {
				if (res.code) {
					//发起网络请求
					wx.request({
						url: 'https://zhoufamily.cn/login',
						data: {
							code: res.code
						},
						success(response) {
							wx.showToast({
								title: "登录成功!"
							})
							console.log(response.data)
						}
					})
				} else {
					console.log('登录失败！' + res.errMsg)
				}
			}
		})
	}

	function handleScancode() {
		wx.scanCode({
			onlyFromCamera: true,
			success(res) {
				console.log(res)
			}
		})
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>